<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.14.
   家居公司在建工地显示($$)*/

!defined('Q_PATH') && exit;

class Buildshow_C_Controller extends InitController{

	public function index(){
		$arrJiajucompany=$this->_oParent->_arrJiajucompany;
		$nId=intval(Q::G('id','G'));

		if(!$nId){
			$this->page404();
		}

		// 在建工地显示
		$arrWhere=array();
		$arrWhere['A.jiajubuild_status']=1;
		$arrWhere['A.jiajubuild_id']=$nId;
		$arrWhere['A.jiajucompany_id']=$arrJiajucompany['jiajucompany_id'];

		$arrBuild=Model::F_('jiajubuild','@A')
			->setColumns('A.jiajubuild_id,A.jiajubuild_title,A.create_dateline,A.jiajubuild_viewnum,A.jiajubuild_progress,A.jiajubuild_realspace,A.jiajubuild_starttime,A.jiajubuild_endtime,A.jiajubuild_realprice,A.jiajubuild_owner,A.jiajubuild_thumb,A.jiajubuild_description')
			->joinLeft(Q::C('DB_PREFIX').'jiajucompanyclass AS D','D.jiajucompanyclass_name AS style_name','A.jiajubuild_styleid=D.jiajucompanyclass_id')
			->joinLeft(Q::C('DB_PREFIX').'jiajucompanyclass AS E','E.jiajucompanyclass_name AS space_name','A.jiajubuild_spaceid=E.jiajucompanyclass_id')
			->where($arrWhere)
			->getOne();

		if(empty($arrBuild['jiajubuild_id'])){
			$this->page404();
		}

		// 更新点击量
		Model::M_('jiajubuild')->updateWhere(array('jiajubuild_viewnum'=>$arrBuild['jiajubuild_viewnum']+1),'jiajubuild_id=?',$nId);
		$arrBuild['jiajubuild_viewnum']++;

		// 读取施工日记记录
		$arrDiarys=Model::F_('jiajubuilddiary')
			->setColumns('*')
			->where(array('jiajubuild_id'=>$arrBuild['jiajubuild_id']))
			->order('jiajubuilddiary_status ASC')
			->getAll();

		Core_Extend::getSeo($this,array(
			'title'=>"{$arrBuild['jiajubuild_title']}在建工地",
			'keywords'=>"{$arrBuild['jiajubuild_title']}在建工地",
			'description'=>"{$arrBuild['jiajubuild_title']}在建工地",
		));

		$this->assign('arrBuild',$arrBuild);
		$this->assign('arrDiarys',$arrDiarys);
		$this->display(Jiaju_Extend::getTemplate($arrJiajucompany,'buildshow'));
	}

}
